// 返回的是一个字符串
let str = Object.prototype.toString.call(123);

// 先看看基本值类型
console.log("Object.prototype.toString.call(123) =",str); //[object Number]
console.log("Object.prototype.toString.call('123') =",Object.prototype.toString.call('123')); //[object String]
// 也可以使用apply来调用
console.log("Object.prototype.toString.apply(true) =",Object.prototype.toString.apply(true)); //[object Boolean]
console.log("Object.prototype.toString.call(Symbol('123')) =",Object.prototype.toString.call(Symbol('123'))); //[object Symbol]
console.log("Object.prototype.toString.call(123n) =",Object.prototype.toString.call(123n)); //[object BigInt]
console.log("Object.prototype.toString.call(undefined) =",Object.prototype.toString.call(undefined)); //[object Undefined]
console.log("Object.prototype.toString.call(null) =",Object.prototype.toString.call(null)); //[object Null]

// 对象，这里用的对象字面量（语法糖）方式创建
let obj = {}
console.log("Object.prototype.toString.call({}) =",Object.prototype.toString.call(obj)); //[object Object]
// 数组也可以使用字面量（语法糖）方式创建
console.log("Object.prototype.toString.call([]) =",Object.prototype.toString.call([])); //[object Array]
console.log("Object.prototype.toString.call(new Number(123)]) =",Object.prototype.toString.call(new Number(123))); //[object Number]

// 使用内置的Symbol常量：Symbol.toStringTag可以改变对象的String描述结果，最终导致此种方式的判断出现错误
let myObj = {
    [Symbol.toStringTag]: "myObj",
}

console.log("Object.prototype.toString.call(myObj) =",Object.prototype.toString.call(myObj)); //[object myObj]